const express = require('express')

const app = express()

// 链接数据库
require('./plugins/db.js')(app)

app.use(require('cors')())

app.use(express.json())

app.use('/upload', express.static(__dirname + '/upload'))

app.use('/images', express.static(__dirname + '/images'))

app.use('/wx/api/images', express.static(__dirname + '/images'))

app.use('/json', express.static(__dirname + '/json'))

app.use('/admin/', express.static(__dirname + '/admin'))

app.use('/', express.static(__dirname + '/client'))

// 管理端的api接口
require('./router/admin/index')(app)
// 客户端的api接口
require('./router/client/index')(app)
// 微信驾照的api接口
require('./router/client/wxsindex')(app)
// 微信websocket聊天室
const http = require('http');
const server = http.createServer(app)
require('./router/client/wxchat')(server)



// app.get('/', (req, res) => {
//   res.sendFile(__dirname + '/socket.html');
// });

server.listen('3000', () => {
    console.log('listening on port: 3000')
})